package GUI;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import connector.Controler;

@SuppressWarnings("serial")
public class PromptPanel extends JPanel{

	private JButton createButton;
	private ArrayList<PokerTable> tables;
	private JComboBox tablesBox;
	
	public PromptPanel(PokerBoard board, int width, int height){
		super();
		this.setSize(width, height);
		this.tables = board.getTables();
		this.setLayout(new BorderLayout());
		this.createButton = new JButton("Create New Table");
		this.createButton.setActionCommand(Controler.NEW_TABLE);
		this.createButton.addActionListener(board);
		this.setBorder(new EmptyBorder(100, 100, 100, 100));
		tablesBox = new JComboBox(tables.toArray());
		JPanel tablesPane = new JPanel();
		tablesPane.setBorder(new EmptyBorder(10, 10, 10, 10));
		tablesPane.add(new JLabel("Available Tables:"));
		tablesPane.add(tablesBox);
		JPanel centerPane = new JPanel();
		centerPane.setLayout(new BoxLayout(centerPane, BoxLayout.Y_AXIS));
		centerPane.add(tablesPane);
		centerPane.add(createButton);
		this.add(centerPane, BorderLayout.CENTER);
	}
	@Override
	public void update(Graphics g){
		tablesBox = new JComboBox(tables.toArray());
		this.repaint();
	}
}
